package com.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

@Aspect
public class AnnoAdvice {
    //切点
    @Pointcut("execution( * com.dao.impl.UserDaoImpl*(..))")
    public void poincut() {}

    @Before("poincut()")
    public void before(JoinPoint joinPoint) {
        System.out.println("这是谴责通知");
        System.out.println("目标类是：" + joinPoint.getSignature());
        System.out.println(",被植入增强处理的目标方法为：" + joinPoint.getSignature().getName());
    }
    @AfterReturning("poincut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("这是环绕通知之前的部分！");
        Object object = joinPoint.proceed();
        System.out.println("这是环绕通知之后的部分！");
        return object;
    }
    @AfterThrowing("poincut()")
    public void afterException(){
        System.out.println("异常通知");
    }
    @After("poincut()")
    public void after(){
        System.out.println("这是后置通知！");
    }

}
